import React from 'react';
import {
    View,
    Text,
    TouchableOpacity,
    Navigator,
    WebView
} from 'react-native';

import FirstPageComponent from '../firstComponent/FirstPageComponent';

export default class SecondPageComponent extends React.Component {

    constructor(props) {
        super(props);
        this.state = {};
    }

    childMethod() {
      const { navigator } = this.props;
      //为什么这里可以取得 props.navigator?请看上文:
      //<Component {...route.params} navigator={navigator} />
      //这里传递了navigator作为props
      if(navigator) {
          navigator.push({
              name: 'FirstPageComponent',
              component: FirstPageComponent,
          })
      }
    }

    _pressButton() {
      const { navigator } = this.props;
      //为什么这里可以取得 props.navigator?请看上文:
      //<Component {...route.params} navigator={navigator} />
      //这里传递了navigator作为props
      if(navigator) {
          navigator.push({
              name: 'FirstPageComponent',
              component: FirstPageComponent,
          })
      }
    }

    render() {
    return (
      <View style={{flex:1}}>
        <WebView
          source={{uri:'http://www.baidu.com'}}
          style={{height:200}}
          javaScriptEnabled={true}
          domStorageEnabled={true}
          scalesPageToFit={true}
          startInLoadingState={true}
          />
      </View>

    );
    }
}
